<?php
/**
 * @author Jimmy Sole
 * @copyright (c) 2010 Jimmy Sole
 * @version 0.1 alpha
 * This program is free to use and/or modify. Please keep this header intact however. 
 */

// use __autoload() to automagically load classes
function __autoload($class_name)
{
	require_once($class_name . ".php");
}

/**
 * @author Jimmy Sole
 * @package Index
 * 
 */
class Index  
{
	/**
	 * @var string holds the username of the user
	 */
	public $username;
	
	/**
	 * @var string holds the password of the user
	 */
	public $password; 
	
	
	/**
	 * @access public
	 * @param pBlahSession $session_info
	 * constructor method loads the layout and checks the user credentials
	 * 
	*/
	public function __construct(pBlahSession $session_info)
	{
		try {
			// check to see if the session was started
			if ($session_info->isStarted() === false) {
				throw new pBlahException("Session has not been started, please login first to fully view this page.");
			} else {
				// validate the user
				if (is_string($session_info->validateSession(array($_SESSION['username'], $_SESSION['password'])))) {
					// load the logged in layout
					echo file_get_contents("index_loggedin_layout.phtml");
				} else {
					// load the not logged in layout
					echo file_get_contents("index_loggedout_layout.phtml");
				}
			}
		} catch (pBlahException $e) {
			echo $e->getMessage();
		} catch (Exception $e) {
			throw $e;
		}
	}
}